<template>
  <svg :class="svgClass" aria-hidden="true" @click.stop="go">
    <use :xlink:href="iconName" />
  </svg>
</template>

<script>
export default {
  name: 'SvgIcon',
  props: {
    // 图标className
    iconClass: {
      type: String,
      required: true
    },
    // 自定义className
    className: {
      type: String,
      default: ''
    }
  },
  computed: {
    iconName() {
      return `#icon-${this.iconClass}`
    },
    svgClass() {
      if (this.className) {
        return 'svg-icon ' + this.className
      } else {
        return 'svg-icon'
      }
    }
  },
  methods: {
    go() {
      this.$emit('goPage')
    }
  }
}
</script>
